jpeg image handling, first approach