Fix serialization
Merge pull request #650 from romainneutron/fix-1292

[3.8] Fix serialization