split ImageMagick functions into separate module

also cleaned up imports a bit