Applied fix to image caching mechanism described in PR #36

Thanks to Giacomo Spigler.
Fixes to docstring formatting and removed trailing whitespace