Bundler: Fix parsing XML template output with encoding declaration

lxml 3.2.1 complains when you try to parse a unicode (in Python 2) or
string (in Python 3) containing an XML document with an encoding
declaration. Traceback:

ValueError: Unicode strings with encoding declaration are not
supported. Please use bytes input or XML fragments without
declaration.

This encodes the document as a string (in Python 2) or bytes (in
Python 3) to avoid the lxml error.  There may be other places this
happens, too, although in most other cases we should use
lxml.etree.parse() to parse a file, or we parse strings (in Python 2)
instead of unicode objects.