World number one Aryna Sabalenka came back from a set and a break down to beat Japan's Naomi Osaka in three sets at the Madrid Open.