Code added to save images as array