create descriptor_writer closure

We use this closure to set the output_dir
variable. I wonder if there is a better way
to do this. Create classes?