Use .encode() instead of str() to support unicode arguments.

str() throws an UnicodeEncodeError for code points that cannot be
represented in 7-bit ASCII. This makes it impossible to use any
non-ASCII characters in module arguments. Using encode('utf-8')
gives the desired result.
Merge pull request #3443 from ajsalminen/arg_unicode_fix

Use .encode() instead of str() to support unicode arguments.