I managed to solve getting the "Malformed data packet" error.....
In my code where is says
// Encode texture into PNG
byte[] bytes = tex.EncodeToPNG();
I changed that to
// Encode texture into JPG
byte[] bytes = tex.EncodeToJPG(30);
which basically saves as a jpg rather than a png.... The difference between the two save types is a larger resulting file (png larger than jpg)....
The orginal code saved the png at 400kb, while the new code saves as jpg at 20kb...
I can only assume the error was caused by the size of the file?