Dreams, writers say, helped create works from ‘The Divine Comedy’ to ‘Frankenstein’ to ‘Stuart Little’