Fix for patch_inplace when the resulting file is smaller than before

Depending on the patch data, the resulting file could be smaller than before.

Since it is opened in append mode, seeking to 0 and writing the patch data would leave the remainder of the file untouched if the patched data was shorter than the original data.

Added the necessary f.truncate() statement. Cheers!