implement_output function

Internal function to implement saving extracted variable to disk or returning into R workspace.