Null-delimited to printf %b converter
Do write and writef automatically buffer writes? If not I bet that's your problem.

One suggestion I do have that you could try is using a final switch statement. It would require an enum containing all the possible values of a ubyte, but in return your switch would essentially be a jump table and a bit faster.
If you're worried about this making your switch look huge you could just mixin the boring portion, generating a string within a loop and adding that string to compilation.

You could also try using a char[128] to store all conversions from ubyte to char, skipping the to! call which might be a bit slower. Making the conversion an array lookup instead of a method call.

This code doesn't use the buffered writes I mentioned, I'll leave that to someone else since I'm unsure about it.

import std.stdio;
import std.conv;

//This enum is so you can use final switch, use a proper ascii order
enum MyEnum { 
    J0, J1, J2, ... //Using J because you can't start identifiers with a number, so I just picked something
    Ja, Jb, Jc, ...
    JA, ...
    ...
}

//a lookup table to make conversion possible in this direction.
static MyEnum[128] reverseMyEnum = {
    J0, J1, J2, ... //in proper ascii order, I know this is wrong
}

//replaces your use of to!
static char[128] ascii = {
    //just put the ascii chars here
}

void main()
{
  foreach (ubyte[] mybuff; chunks(stdin, 4096)) {
    encodebuff (mybuff);
  }
}

@pure string generateBoring() {
    string code;
    for (char value; a .. z, A .. Z, 0 .. 9)
        code ~= "case MyEnum.J'"~value~"': writeChar(b); break;\n";
    for (char value; any other uncaught cases)
        code ~= "case MyEnum.J'"~value~"': writeOctal(b); break;\n";
    return code;
}

@safe void encodebuff (ubyte[] mybuff) {
  foreach (ubyte i; mybuff) {
    char b = ascii[i]; //integer promotion lets you use a ubyte where int is expected
    final switch (reverseJB[i]) {
        mixin(generateBoring());
        case 0: writeChar ('\n'); break;
        case MyEnum.JBackBack: writeString(`\\`); break;
        case MyEnum.JBackT: writeString(`\t`); break;
        case MyEnum.JBackN: writeString(`\n`); break;
        case MyEnum.JBackR: writeString(`\r`); break;
        case MyEnum.JBackF: writeString(`\f`); break;
        case MyEnum.JBackV: writeString(`\v`); break;
        case MyEnum.JBackA: writeString(`\a`); break;
        case MyEnum.JBackB: writeString(`\b`); break;
    }
  }
}

@trusted void writeString (string a)
{
  write (a);
}

@trusted void writeOctal (int a)
{
  writef ("\\%.4o", a); // leading 0 needed for for zsh printf '%b'
}

@trusted void writeChar (char a)
{
  write (a);
}