Python 3

Fixes some Python3.x compatibility problems I found.