Use writev(2) for stdio

Begin cleanup of code by replacing usage of write + malloc with writev.