cmake support for ImageMagic vs. libavcodec

And some other related fixes