Fixed calculation of array layers in read_image functions.