Fix for negative object width and height

New pull request for #378