encode maps into dictionaries