py3.x compatibility fixes