Adding strict versions of encode and decode