Fix caching issue while image transformation #4662

* Removed tempfile dependency.
* Fixed caching issue with images.
* Added test for the same.
* Re-factored test.
fromtimestamp by default returns the time in local tz (but a tz naive dt).

```python
from pytz import timezone

datetime.fromtimestamp(os.path.getmtime(filename), timezone('UTC'))
```

also i'd prefer if this is a separate variable and then compared just for the sake of readability,.