fixed error in making the image to matrix conversion