More Python v3 compatibility fixes