Bug fixes from testing on Windows. Imagemagick code rewritten.