Python3 compatibility fixups