public function writeBytes(Stream $stream, $bytes, $length = null)
    {
        if ($length === null) {
            $length = mb_strlen($bytes, '8bit');
        }

        $stream->write($bytes, $length);
    }