Search for %%EOF in the last 1024 bytes

With full Py3 compatibility.
manual merging