python3 compatibility fixes