Fix develop

- [Forked XMLWriter](https://github.com/dimagi/XMLWriter) and applied escaping fixes ([PR](https://github.com/alexandern/XMLWriter/pull/6) submitted upstream)
- Use `writeXML` instead of `writeString` in places where XML characters should not be escaped.
- Minor code cleanup.