better error messages in rawextract
fix error check
splitted prepare_jpeg into several functions