lua : add a way to export images directly with format objects

<format>.write_image(format,image,filename)

will export the image to filename using format.

this call is blocking. Another function will be provided to queue images at some point