Refactored the section and optional header write implementations out of the ImageWriter class