Convert error object to string in output_spec

Update output_spec to an convert error object to string in case it is
not already a string. In such a case, the object should be a table with
the __tostring metamethod defined, making it convertible to a string.