[PIR-994] - Fixed encoding issue with Metadata domain save, by recoverin...

...g old code and fixing issue in ByteArrayInputStream creation