use RAII to manage resources, simplify and remove malloc/free
avoid allocating images larger than 4096*4096
check image_ptr prior deref
Merge pull request #351 from mapnik/image_data

use RAII to manage resources, simplify and remove malloc/free