Fraser,
I would change the maximum number of images to a very large number in MAX. This will allow you to allocate as many images as will fit in the memory of your computer. There is no need to convert them to an array, which just adds overhead to the program.
If you need to store more images than you have memory for, you will need to look at streaming them directly to disk. There are a few methods for doing this out there. I haven't researched which one is best.
Of course, another option is to buy more memory for your computer, which is usually the cheapest option available.
Bruce
Bruce Ammons
Ammons Engineering