Support multiple backends and add alloc backend

Consider actually returning the error from `fmt.Fprintf`, and then checking error when calling this function.