Fix UnicodeEncodeError in to_url for oauth2