Changed bounding box algorithm to get extreme external contours