2to3: Apply urllib fixer.

Various functions have been moved around in the stdlib for Python 3,
this fixes that up so that the code is valid in both Python 2 and
Python 3.

Note: monkey patching the stlib urlopen for testing looks a bit hokey
to me, but I don't see an easier, more reliable way to do the test.

Closes #3090.