added code from http://sites.inka.de/tesla/others.html#bsdiff