Avoid buffer issues in XML encoder.

See https://code.google.com/p/owasp-java-encoder/issues/detail?id=4