Better filenames, error handling, and output formatting

Change-Id: Iaea8965e13de926fdf077812a3a314b43dcec667