Van Riemsdyk's second-period goal put the Maple Leafs ahead 2-1, but the Devils' Ryane Clowe answered with his first of the season less than a minute later.
After a scoreless third period and overtime, the game moved to a shootout.
Van Riemsdyk went first and lifted a backhander over the glove of Cory Schneider.
Tyler Bozak scored in regulation and Bernier turned aside 36-of-38 shots for the Leafs.
Clowe notched an assist, Adam Henrique also scored and Schneider made 23 saves for New Jersey, which had its two-game winning streak snapped.
Celebrity Breakups and divorces of 2014 [PHOTOS]