Py3k compatibility fixes in two-phase rendering

``request.content`` is always bytes, not text, so all the strings that are used to manipulate it should also be bytes.

Fixes #843.