Roger Federer recovered from dropping his first set of the tournament to race into the fourth round of the US Open with victory over Marcel Granollers.