Optimize mean and quantile post-processing (classical hazard)

The first set of changes for https://bugs.launchpad.net/openquake/+bug/1087661.

This branch basically re-writes the existing mean/quantile post-processing. If these changes are satisfactory, I'd like to remove the old post-processing code in a separate branch.