Python 3 compatibility

The work to change this library to become Python 3 compatible is not big. I have made some changes already.