fixed a bug where the output buffer was too small.