fixed orientation bug, and bug for 3d images being incorrectly allocated