Change toString() to use string stream instead for compatibility on all platforms