Support python 3

Progress on #219

The test suite passes, but I ran into some errors while trying to run it under python 3.4 manually (https://github.com/d11wtq/dockerpty/issues/8 is the first).

It might be a good idea to have the test suite running python3 even if it doesn't work for real yet. That way new code will have to be compatible and it'll be less work to fix the remaining python3 issues (as we add tests which expose the problems).