encode decode on the fly example