You take the bytes in the array, pair out 6 bits at a time, write that number in Base64, and write that value into a string. Put this string into your XML (it's going to be very long).
some source code of this technique:
There is other techniques as well, this one is just commonly used for clear text transmission of data.
Some might ask why not just use the entire UTF-8 character space which would eliminate the 30% increase in size of the file... that's because the characters outside of these 64 characters are reserved characters for various things. Not even CDATA would fix this because control characters exist in those 256 characters that may act as a flag on a server or in a network, or even a random binary sequence could terminate your CDATA.
Of course you could devise an algorithm around this as well, and such clear-text encoding algorithms DO exist. Base64 merely exists as a long time common clear-text encoding technique, the algorithm being very simple, and nearly all computer systems out there can deal with it easily. And I suggest it for the ease of use.
Oh just so you know, I use B64 encoding for several things in a program I write for work. It's in .Net, but the algorithm is identical (and MS has the algorithm built into .Net). I just encoded a random jpeg I had laying around... The image I encoded was 604x453 pixels in size, with jpeg encoding. The resulting string once converted to B64 was only 61,340 characters long. YEs a very long string, but not impossibly long and could easily be stored in xml.
That's only 60kB in data, I've seen XML files far larger than 60kB.