fixes bug 977183 - UnicodeEncodeError due to use of str(), r=AdrianGaudebert