fix some python3 compatibility issues