Percent encode base url

This fixes issues when references are in a path with spaces or with
special characters.

Fixes issue #6.