Better error handling calling imagemagick

Change-Id: Id9ff872a1ea0babeeee9e338ce3628bd9790d36c