Cleanup path handling (os.path.join and more)

This pulls commits 5517d79, 2b35d12, and 4e9b5c1 (the 5th, 6th, and
7th) off the bottom of #671.  This PR is independent of #767, but you
may want to apply it after #767 to preserve #671's ordering.

The `path_to_url` commit is new for this PR, and the `os.path.join`
commit has been extended to also cover a number of places where 'a/b'
or similar was hard-coded.