optimized homeController image handling

I put the whole image handling in a class & functions which I then can
call from the controller, reducing the spaghetti code in the
homeController and improving readability of the image handler