Two-time US Open champion Naomi Osaka overcame 41 unforced errors to beat Elise Mertens 6-3, 3-6, 7-5.