title: Change class of elements in list and save with element name
body: <p>I have a list of elements of type "<code>im</code>" </p>
  
  <pre><code>mylist
  $sp1
  $sp2
  $sp3
  </code></pre>
  
  <p>and I want to convert them to a list of elements of class "<code>SpatialGridDataFrame</code>"</p>
  
  <p>This works for a single object of class "<code>im</code>":</p>
  
  <pre><code>a &lt;- mylist$sp1
  b &lt;- as(a, "SpatialGridDataFrame")
  </code></pre>
  
  <p>Then I want to save each element in the new list b as a .TIFF file, with the name of each element in the list (sp1.TIFF, sp2.TIFF, etc.)</p>
  
  <p>This also works for a single object in package "rgdal":</p>
  
  <pre><code>writeGDAL(b, "sp1.TIFF")
  </code></pre>
  
  <p>Any clue?</p>