Python 3 compatibility

This awesome library needs some changes to be compatible with Python 3.