Correct type of Content-Length headers.

This should resolve #1113. A test is included, but the test relies on StringIO - if you want to avoid that import, I can remove the test.

As a side note, the type of the Content-Length header is now always unicode, which feels pretty weird. Should I add in a call to `encode('ascii')`?