dont let image processing unless it is an image.

if any user uploads a pdf file, `image_magick` takes quite a lot of time to determine whether it's a valid image or not. It hangs the server for some time depending on the size of the file. this pull request fixes this issue.