Use reference thumbnails for JPEG/PNG thumbnailing on beta sites

This will cause PNG/JPEG thumbnails to be generated in chains:
full size -> 4096px -> 2048px -> 1024px -> 512px -> 256px -> requested size
Since the intermediary thumbnails are retained, this will cause the
first request to be slower and subsequent requests to be significantly
faster. A survey run on wikitech-l shows that the quality loss is
unperceivable.

This change is limited to beta sites and is only meant to check that the
feature actually works and does not break anything. The list of
thumbnail buckets was picked with the aim of limiting the quality loss
from one bucket to the next, and are not nexesseraly the ones that
will be used for a future production deployment.

Depends on core change I285d56b2024c81365247338f85c1e0aa708cb21e

Bug: 67525
Change-Id: I07e38eba64d53d3365756f18da8c35d233d14e9f
Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/600