Make EncodedFile, used for captured output streams, method .write return the number of characters written. Add test for captured stderr write. Fixes #6557. Co-Authored-By: Bruno Oliveira <nicoddemus@gmail.com>