I/O error reading image metadata

Have you updated the snappy.ini to a higher memory value?
Have a look here:

If this doesn’t help it would be good to see more of your code.