Bug fix, clear the memory that was allocated for the images