pthread: Fixed a mem leak with images.