Python 3 compatibility

Likewise, just fixed some stuff up for python3