Fix unicode versus bytes issues in wsgi code, a HTTP body is a bytes
string. Changes:
* On Python 3, encode JSON to UTF-8.
* Replace file() with open(); file() was removed in Python 3.
* Use literal byte strings (b'...') for HTTP body.
* Use binary instead of text mode for HTTP body when getting a file from
a socket (sock.makefile).