Finished writing the free image function.