Add output option
Use memory stream instead of temp files