change the way to convert upside down image

Swap of all the pixels become slower as image size increases.
Therefore, convert an image using Matrix class instead.