fixed memory leak
implemented deallocation of contour sets and fixed a few memory leaks
Fixed numerous memory leaks in contour detection
Fixed memory leak in image saving code