Rotate the image matrix