Fix temporary image file creation

The current implementation of `show(image)` in `pylearn2/utils/image.py` causes an EBADF
(Bad file descriptor) error on some environments such as Mac OS X 10.8.0.
This is because invocation of `file.flush()` for a file opened with *read-only* mode may cause the
EBADF error in some environments.
See also:
- https://mail.python.org/pipermail/python-bugs-list/2002-June/012231.html
- http://www.opensource.apple.com/source/Libc/Libc-825.40.1/stdio/FreeBSD/fflush.c

This pull request re-implements the function with `tempfile.mkstemp()`.
It also resolves a race condition which may occur on Python older than 2.7.