Make Python 3 compatible.

Make sure it tests and runs clean with both Python 2 and Python 3.