Hi Nick,
I remembering seeing similar behaviour in Maxim DL if I didn’t set the options to save the stretched image to the dynamic range of the output file. I think what is happening is you are displaying the image with a certain stretch applied to the image brightness, setting what is dark to light. However, what is being saved is unstretched or a different dark to light stretch. This may be more important for jpeg as I think they have a limited dynamic range of 8-bit.
Best wishes,
Andy