HDR writing bug fix