Add support for nested output buffers

This uses the ob_get_level command to work out how many output
buffers we need to close before we make our own output.

This enables using PHP-Error in applications such as magento.