Make compatible with both Python 2 and 3

This makes it possible to run test_server_thread.py with Python 3 too.