Merging back in changes to write an .rsc file in create_roi_in

This code likely needs some polishing up...