fix Stack consistency error under mingw environment

Under mingw environment, sp.write causes stack consistency error because it returns C int to Ruby. INT2FIX address the error. Please review the code and pull if possible.