Naomi Osaka beat Anett Kontaveit in three sets to reach the semi-finals of the Western and Southern Open at Flushing Meadows.