Reverting c5c5951, could have side effects.

    The fwrite functions writes (size * nitems) bytes from 'ptr', and
    then returns the number of items written. In the snippet:
        if (encoded && ! fwrite(buffer, 1, encoded, output)) {
            return ENOWRITE;
        }
    any non-zero return value is considered a successful write, however
    if fwrite decides to write fewer than 'encoded' bytes, but more than
    1 byte, the statement will consider it a success. If instead we list
    'encoded' as the size, and say there is only 1 item, the snippet
    will succeed *only* when the entire buffer is written.