Fix bugs in export encoding