Fixed some bugs and added mysql loggin
Fixed some bugs and added mysql logging of the images