dtc: make dtc build pass under Windows

Windows CRT does not provide lstat and asprintf APIs, instead use
stat and snprintf for an alternate.

Note __MINGW32__ macro is used to provide build time differentiation
when compiling under Windows using MinGW toolchains.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
dtc: use binary mode for file handling

On Windows file operation APIs like fopen/fread/fwrite use text mode
by default, instead of binary mode like other *nix platforms. Text
mode will break the dtc output when handling Carriage Return (CR)
and Linefeed (LF). The change updates Windows default file handling
mode to binary mode.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>