Port to python3

Only a port to python3. I'm not good with pull requests. If I'm doing anything wrong, please notice.