Added alternative imagick library implementation for the image handling.

Improved memory management for the GD library image handling.