Add support for Tornado 4

I haven't run the Tornado test suite against this change but it works with a simple web server implementation. This should be the only compatibility change that matters from Tornado 4.0 (see http://www.tornadoweb.org/en/stable/releases/v4.0.0.html#backwards-compatibility-notes).