sim: Add some debug code to dump images

The code is commented out, but can easily be uncommented to allow the
various images to be dumped out for external analysis.
diff --git a/sim/src/flash.rs b/sim/src/flash.rs
index 5b04bf6..83ef771 100644
--- a/sim/src/flash.rs
+++ b/sim/src/flash.rs
@@ -3,7 +3,10 @@
 //! This module is capable of simulating the type of NOR flash commonly used in microcontrollers.
 //! These generally can be written as individual bytes, but must be erased in larger units.
 
+use std::fs::File;
+use std::io::Write;
 use std::iter::Enumerate;
+use std::path::Path;
 use std::slice;
 use pdump::HexDump;
 
@@ -138,6 +141,13 @@
     pub fn dump(&self) {
         self.data.dump();
     }
+
+    /// Dump this image to the given file.
+    pub fn write_file<P: AsRef<Path>>(&self, path: P) -> Result<()> {
+        let mut fd = File::create(path).chain_err(|| "Unable to write image file")?;
+        fd.write_all(&self.data).chain_err(|| "Unable to write to image file")?;
+        Ok(())
+    }
 }
 
 /// It is possible to iterate over the sectors in the device, each element returning this.