Added correct size extraction when saving images