AVI parser clean up, moved writeback to its own function ready for the flushing to disk stuff