Refactor fetch-image to cache-uri.

- Give it a better name as the function is generic enough to cache any
  uri input stream.
- DRY up the output file name.