improved patcher to be able to unpatch

also, refactor logic a bit
also, do not use temporary file

Signed-off-by: Marian 'VooDooMan' Meravy <vdm113@gmail.com>