I've seen a lot of posts on this subject that don't seem to have been resolved so I just have to share my experience with the issue.
I noticed that it only happened with certain images so I checked and the images it was happening with, while small file sizes, were very high dimensions (2000px or more wide). All I had to do was decrease the image size to 1000px wide and it worked fine.
So, as I've said, its not the image size its the image dimensions that is causing the error.
One more thing i've noticed is that several people have said they were hosted with 1and1 and the website that I had the error with was also hosted on 1and1.