Based on http://hg.pablotron.org/zipstream-php/