Save output to arbitrary files

Fixes #1.