fixed error in transforming image from array to matrix