[python3] Fix remaining portability issues