Hmm, I know Yonatan's version used an LPTSTR for the output buffer, which seemed to work just fine (on the Encode method). I don't know if that helps..