Add flash writing
Fixup flash according to marti's comments

Signed-off-by: Manuel Odendahl <wesen@ruinwesen.com>