Fix some python 3 incompatibilities