Py3k compatibility fixes in two-phase rendering