Having a code that works for ages when loading and storing images, I discovered that I have one single image that breaks this code:
const string i1Pa
In my case I have accidentally deleted the directory where image was getting stored.