Preliminary port to Python 3 API.

Will also use the new asyncio framework rather than gevent.