Free scratch buffer with scr_free instead of buf_free

I also now allocate the scratch buffer to the correct size to avoid unnecessary growth in buf_fmt.