Merge fixes from ImageMagick official trunk