Restore old code for integer/string conversions

Simple C loops are faster than using stringstream.