Created Utils class for converting image formats
Reorganized code

The old code was a mess, because it was copy pasted from a random
website. It should be a lot cleaner now and easier to work with.