py3k compatibility fixes