Update XMLWriter.php

Modifying the way Encoding is handled.  Offloading it to separate protected method.

TODO: Enable custom mb_detect_order setting.