ImageIO.read fails to read ByteArrayInputStream for image

Sorry about that, I’ve edited the code to be more clear. The error happens in the first script I posted, on the call ImageIO.read(bais), where bais is my byteArrayInputStream created from the custom string property that is passed the bytes from the call to readFileAsBytes. It seems that readFileAsBytes succeeds, ByteArrayInputStream succeeds (since I am able to print bais.available() which tells me how many more bytes are available in the stream), but ImageIO.read returns null when it should be creating a BufferedImage object.
I posted the additional script just in case my method of passing data (via custom properties) is incorrect.

Is there a size limit on custom string properties? perhaps some trailing data has been cut off?