[PY3] Use six to select urllib import.

Adds the six.py compatibility layer for seamless Python 2/3 use of
urllib2/urllib.

Also fixes a bug (only in Python 3) caused by the fact that local
variables in things like try blocks, loops and list comprehensions are
not visible outside that scope.
[PY3] Make compression Python 2/3 compatible.
[PY3] Added wrapper for Python 2/3 test compat.
[PY3] Made compression in test_api 2/3 compatible.
[PY3] Removed extra string conversion in sqlite cache.