fixed bugs and added code to write bounding boxes to files