fix writing both kind of figures

split figures into 2 kinds text and binary

fixes #107