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.

Note: I need to run all fo the QA tests, so I may add more commits to fix any issues that arise.