PEP8 cleanups, improved Python 3 compatibility

We are not still compatible with Python 3, but these changes get us closer
to that goal.