Rewrite Package-Merge

* src/encode.c (package_merge): Rewrite from scratch basing on
Java implementation in lbzip2-java.