fixed memory leak.
fixed usage of freeimage init/deinit and added a comment.