Fix call to sanitize_illegal_chars_for_xml.

The newly-added sanitize_illegal_chars_for_xml method was being called after we
had encoded the unicode string into bytes, and doing the regular expression
substitution would then try to coerce those bytes back to unicode using the
ascii codec. Doing the sanitization on the unicode object, and then encoding to
bytes works correctly.

Testing done:
Ran unit tests. Before the fix, this failed with the same error as the reported
issue. After, it runs successfully.

Reviewed at https://reviews.reviewboard.org/r/6678/
Merge branch 'release-2.0.x'