Fix encoding errors when hashing XML

We occasionally get UnicodeEncodeErrors from these two places,
because the XML is a Unicode string, and is implicitly encoded to ascii.