move encode dframe and add_id, closes #541