I have base64 String which I want to convert back to image irrespective of image format at server side. I tried it by using following code, image is getting created but when I am trying to preview it, showing error could not load image. 

```
public void convertStringToImage(String base64) {
        try {
            byte[] imageByteArray = decodeImage(base64);

            FileOutputStream imageOutFile = new FileOutputStream("./src/main/resources/demo.jpg");
            imageOutFile.write(imageByteArray);
            imageOutFile.close();
        } catch (Exception e) {
            logger.log(Level.SEVERE, "ImageStoreManager::convertStringToImage()" + e);
        }
    }

    public static byte[] decodeImage(String imageDataString) {
        return Base64.decodeBase64(imageDataString);
    }

```

what should I do so that my image will look properly?