Normally, data files are written by the micrscope, but if you happened to have a reason to write one yourself, you can use the IDL routine write_stxm5.pro:
IDL> write_stxm5, filename, sm_par, image_data
The sm_par structure must have the correct form as defined by sm_ipar_stxm5.pro. image_data must be a 3-d uint array in the form of image_data_intraw (see Chap. 9). If the file already exists, the program produces an error and doesn't write the file unless you set the keyword /overwrite.