This is a fixed version for FlushGeneratedImagesTask such that it regenerates images instead of silently removing them and breaking existing pages

The pull request also contains some enhancements and fixes to the corresponding testcases.

Fixes #318