fix unicode error

by casting string and passing utf8 argument to unicode calls
was raising a UnicodeDecodeError on non-english systems
Merge branch '4770-fix-unicode-error'