Pack and encode