Python3

This ports a number of modules to python3. 

I've split the work up in to a commit per module. Please feel free to review the commits one at a time.

I've reintroduced what I had in _compat.py into a _py3_compat.py. I will keep this small, only the really repetitive stuff. 


integer_types only appears to be used in one place.