fixed bug for reading the images