image cleanup, and fitting contours