Fixed python3 compatibility issues.