Cannot upload profile icon

When I upload a profile icon I get the error:

Sorry; there was a problem uploading your profile picture.

I have debug turned on but the only suspicous thing I can see is:

Page /elgg15/pg/icon/sm00ay/master/.jpg generated in 0.380502939224 seconds

the following is present but empty in the data dir, so it's writeable:

s/m/0/0/a/sm00ay/profile/

the icon is a 39x67 jpg. I also tried a bigger 197x338 jpg.

Are there restrictions on the photos in any way?