Contour following and reconstruction of binary images stored in run format