This commit adds support for Python 3 in such a way that exactly the
same code works with both Python 2 and Python 3, i.e. no 2to3 or other
conversions are needed.
I tested the code by running the unit tests with Python 2.6 and 3.2,
and Tornado 2.0.