compatible with python-2.6

Fixes two issues in generators/xml.py when using python-2.6.

The main problem is caused by incompatible between xml.etree.ElementTree-1.2
(used by pyhton-2.6) and xml.etree.ElementTree-1.3 (used by python-2.7).

+ ElementTree.register_namespace(prefix, uri)
  Workaround by:
  ElementTree._namespace_map[uri] = prefix

  This solution is based on http://goo.gl/Z4Sjtq

+ ElementTree.write(file, encoding='utf-8', xml_declaration=True)
  Workaround by:
  ElementTree.write(file, encoding='UTF-8')

  This solution is based on http://goo.gl/8K88ow (pls check Olli's answer)

Signed-off-by: Kai Zhang <zhangk1985@gmail.com>