Make sure unicode URLs are encoded as UTF-8

If the server URL is unicode, then trying to make requests would end up with an
encoding conflict between different headers. The bug included a simple fix that
makes urllib happy: manually encoding the url as utf-8 into a string object.

Fixes bug 2238.