EPUB writer: correctly resolve relative URIs.  (Closes #1671.)
EPUB reader:  Further URI handling improvements.

Now we outsource most of the work to `fetchItem'`.
Also, do not include queries in file extensions.

Improves fix to #1671.

It is possible that this will have some unexpected effects, so
further testing would be good.