Windows: fix possible buffer overflows

Fix improper use of MultiByteToWideChar() that could have led to
buffer overflows.