Fix for bug #41357, by moving byte array creation until after we've decided that we have a valid picture