Pull ToSql and FromSql out into their own module

Their implementations will become significantly more complicated once we
start handling binary data.