Encode URL strings using URI's toASCIIString() method.

This makes Unicode in paths work correctly when the Java system
encoding isn't set to UTF-8.

Thanks to Marcel M for reporting the issue.