Add Python 3 compatibility and encode binary payloads with UTF-8

Before the socket would have failed with an error due to missing encoding. I did some tests and saw that the server socket will decode a UTF-8 string transparently, but dd-agent should probably be updated to decode UTF-8 strings explicitly. This will probably be necessary if dd-agent supports Python 3.
add `six` here?