Even better emulate POSIX file functions (reduced)

This is reduced version of #5694.
Only obvious fixes.
POSIX explicitly require casting to `unsigned char`: http://pubs.opengroup.org/onlinepubs/009695399/functions/fputc.html
Don't see any reason to use such replacement type here.