jpeg2000: Templatize the frame writer