refine jpeg_segmenting to consider header lengths