Backport encode URI patch

Backporting patch for encoding URIs from 0.8.0 to 0.5.8 branch. Encodes URIs that have a + in them, such as s3 urls.