Use more specific exception types
Rewrite index building

zlib.inflate filter has a number of flaws:
- Stream read buffer must be cleared with fseek()
- ftell() does not report actual file position after reading zlib
- No way to know num. bytes before decompressing

As a workaround Packfile first decompresses data, then recompresses it
and measures the result.  It is slow but the only way.
Write index built from packfiles
Write index file directly from Packfile object