encode content before using as in memory file

File handles should always have content in encoded form, not as unicode
characters.  perl 5.17.9 starts warning about this for in-memory file
handles.  This encodes the content used in the test before using it in
an in-memory file handle.
Merge pull request #204 from haarg/fix-request_upload

encode content before using as in memory file