The answer is simply: writeFile sure can write those and it shouldn't break it.
I do essentially the same here, the only difference is where the image comes from: [https://github.com/brentp/nim-plotly/blob/master/src/plotly/image_retrieve.nim#L119](https://github.com/brentp/nim-plotly/blob/master/src/plotly/image_retrieve.nim#L119) And I just ran your first code and it works fine on my end.