Ported Yara to the new I/O

I rebased the feature branch to solve the conflicts.

Known issues:
* SAM output seems to be 40% slower than before;
* I observed random aborts towards the end of the output file, e.g. when writing the last buffer.

The above issues needs further investigation. Nonetheless, this PR can be merged as I previously tagged yara-v0.9.0.