jellybean: simplified writing routine for trivial files and a guard for file names from shell expansion

Writing of the trivial files (the files which are written in one operation and closed)
was a bit wasteful by using stdio (fopen/fprintf/fwrite) routines. Use of just three
syscalls (open/write/close) is entirely justified here and reduces memory use and
code size.

This particular case wont profit much from the change (the code is relatively rarely
used), but it might set a good precedent.

A change in use of __system is actually a bug fix: the old code could not handle
files names with spaces and special characters in them at all. The whole code in
the file should be re-audited with regard to proper shell quoting: its (ab)use of
shell for even trivial operations disregards even basic rules of passing strings
to shell interpreter: the variables are almost never quoted. Besides, calling up
to shell is very slow.